package com.wtx.test2017;

/**
 * @description: 2017试题第二题第一问
 * @author: wtx
 * @createDate: 2020/6/10
 */
public class Test2_1 {

    private int num = 0;    //加法运算次数
    // 求 2^n
    public int solution(int n){

        if (n<0)
            throw new IllegalArgumentException("n must be positive integer");

        if (n == 0)
            return 1;

        num++;
        return solution(n-1)+solution(n-1);
    }

    public static void main(String[] args) {

        Test2_1 test21 = new Test2_1();
        System.out.println(test21.solution(1));
        System.out.println(test21.num);
    }
}